#include "map.h"


Map::Map()
{
    //初始化地图
    m_map1.load(MAP_PATH);
    m_map2.load(MAP_PATH);

    m_map1 = m_map1.scaled(GAME_WIDTH, GAME_HEIGHT, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
    m_map2 = m_map2.scaled(GAME_WIDTH, GAME_HEIGHT,Qt::IgnoreAspectRatio, Qt::SmoothTransformation);


    //初始化y坐标
    m_map1_posY = -GAME_HEIGHT;
    m_map2_posY = 0;

    //地图滚动速度
    m_scroll_speed = GAME_SCROLL_SPEED;
}

void Map::mapPosttion()
{
    //处理第一张图片的滚动位置
    m_map1_posY += m_scroll_speed;

    if(m_map1_posY >= 0)
    {
        m_map1_posY = -GAME_HEIGHT;
    }

    //处理第二张图片的滚动位置
    m_map2_posY += m_scroll_speed;

    if(m_map2_posY >= GAME_HEIGHT)
    {
        m_map2_posY = 0;
    }

}
